package test.test3;

import java.lang.reflect.Proxy;

public class ProxyFactory {

    public Object duiXiang(String type){
        Object computer=null;
        switch (type){
            case "加":
               computer= new Add();
                break;
            case "减":
               computer=new Reduce();
                break;
            case "乘":
                computer=new Ride();
                break;
            case "除":
                computer=new Except();
                break;
            default:
                System.out.println("没有这种");
                break;
        }
        return computer;
    }
    public Computer fangFa(String type){
       Object object= duiXiang(type);
        return  (Computer) Proxy.newProxyInstance(object.getClass().getClassLoader()
                , object.getClass().getInterfaces()
                , new JdkProex(object));

    }
}
